(:: pragma bea:global-element-parameter parameter="$inventoryCheck1" element="ns0:InventoryCheck" location="../WSDLs/InventoryCheck.wsdl" ::)
(:: pragma bea:global-element-parameter parameter="$outputParameters1" element="ns1:OutputParameters" location="../Adapter/OracleInventoryAdapter/xsd/OracleInventory_QueryStatus_sp.xsd" ::)
(:: pragma bea:global-element-return element="ns0:InventoryCheckResponse" location="../WSDLs/InventoryCheck.wsdl" ::)

declare namespace ns1 = "http://xmlns.oracle.com/pcbpel/adapter/db/sp/OracleInventory_QueryStatus";
declare namespace ns0 = "http://www.example.org/InventoryCheck/";
declare namespace xf = "http://tempuri.org/ActivateNewCustomer/Transformation/InventoryCheckResponseFormat/";

declare function xf:InventoryCheckResponseFormat($inventoryCheck1 as element(ns0:InventoryCheck),
    $outputParameters1 as element(ns1:OutputParameters))
    as element(ns0:InventoryCheckResponse) {
        <ns0:InventoryCheckResponse>
            {
                for $ITEM_NUMBER in $outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:ITEM_NUMBER
                return
                    <SKU>{ data($ITEM_NUMBER) }</SKU>
            }
            <serial_mac>{ data($outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:SERIAL_MAC) }</serial_mac>
            <status>{ data($outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:STATUS) }</status>
            <customerId>{ data($outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:CUSTOMER_ID) }</customerId>
            <serviceId>{ data($outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:SERVICE_ID) }</serviceId>
            <partnerId>{ data($inventoryCheck1/partnerId) }</partnerId>
            <mvnoReferenceNumber>{ data($inventoryCheck1/mvnoReferenceNumber) }</mvnoReferenceNumber>
            <amdocs_user_id>{ xs:string($outputParameters1/ns1:CURSOR_OUT/ns1:CURSOR_OUT_Row[1]/ns1:AMDOCS_USER_ID) }</amdocs_user_id>
        </ns0:InventoryCheckResponse>
};

declare variable $inventoryCheck1 as element(ns0:InventoryCheck) external;
declare variable $outputParameters1 as element(ns1:OutputParameters) external;

xf:InventoryCheckResponseFormat($inventoryCheck1,
    $outputParameters1)
